package edu.example.order.Dao;

import edu.example.order.bean.User;
import edu.example.order.test.ConnectionFactory;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class userDaoImpl implements userDao{

    @Override
    public User findByNameAndPwd(String name, String password) {
        Connection connection= ConnectionFactory.getConnection();
        String sql="select * from user where StudentID=? and password=?";
        try {
            PreparedStatement preparedStatement=connection.prepareStatement(sql);
            ResultSet rs=preparedStatement.executeQuery();
            while (rs.next()){
                User user=new User();
                user.setId(rs.getInt("id"));
                user.setName(rs.getString("name"));
                user.setPassword(rs.getString("password"));
            }
          } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return null;
    }
}
